using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Practices.RecipeFramework;
using VSSDKAssist.Assets.Actions.Base;
using System.Globalization;

namespace VSSDKAssist.Recipes.CreateVSCommand
{
	/// <summary>
	/// Action that adds the corresponding entries to a ctc file
	/// </summary>
	public class CreateCommandDefinitionAction : ActionBase
	{
		#region Properties
		private string groupName;

		/// <summary>
		/// Gets or sets the name of the group.
		/// </summary>
		/// <value>The name of the group.</value>
		[Input(Required = true)]
		public string GroupName
		{
			get { return groupName; }
			set { groupName = value; }
		}

		private string commandName;

		/// <summary>
		/// Gets or sets the name of the command.
		/// </summary>
		/// <value>The name of the command.</value>
		[Input(Required = true)]
		public string CommandName
		{
			get { return commandName; }
			set { commandName = value; }
		}

		private string commandCaption;

		/// <summary>
		/// Gets or sets the command caption.
		/// </summary>
		/// <value>The command caption.</value>
		[Input(Required = true)]
		public string CommandCaption
		{
			get { return commandCaption; }
			set { commandCaption = value; }
		}

		private string commandDefinition;

		/// <summary>
		/// Gets or sets the command definition.
		/// </summary>
		/// <value>The command definition.</value>
		[Output]
		public string CommandDefinition
		{
			get { return commandDefinition; }
			set { commandDefinition = value; }
		} 
		#endregion

		/// <summary>
		/// Called when [execute].
		/// </summary>
		protected override void OnExecute()
		{
			// Command                             Parent Group						 Priority  Image			Type    Visibility Text
			//guidVsPackage1CmdSet:cmdidMyCommand, guidVsPackage1CmdSet:MyMenuGroup, 0x0100,   guidMyCommand:1, BUTTON,		   	   , "My Command name";

			commandDefinition =
				string.Format(
					CultureInfo.CurrentCulture,
					"    guid{0}:cmdid{1}, guid{2}:grpid{3}, 0x0100, guid{4}Bitmap:1, BUTTON, , \"{5}\";",
					this.commandName,
					this.commandName,
					this.commandName,
					this.groupName,
					this.commandName,
					this.commandCaption
					);

			//TODO: Add support for Visibility
		}
	}
}